<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Zend_Service_Amazon_Ec2: Elastic Block Storage (EBS) - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.service.amazon.ec2.ebs.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.service.amazon.ec2.ebs.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.service.amazon.ec2.images.html">Zend_Service_Amazon_Ec2: Amazon Machine Images (AMI)</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.service.html">Zend_Service</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.service.amazon.ec2.elasticip.html">Zend_Service_Amazon_Ec2: Elastic IP Addresses</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.service.amazon.ec2.ebs" class="section"><div class="info"><h1 class="title">Zend_Service_Amazon_Ec2: Elastic Block Storage (EBS)</h1></div>
    

    <p class="para">
        Amazon Elastic Block Store (Amazon EBS) is a new type of storage
        designed specifically for Amazon EC2 instances. Amazon EBS allows
        you to create volumes that can be mounted as devices by Amazon EC2
        instances. Amazon EBS volumes behave like raw unformatted external
        block devices. They have user supplied device names and provide a block
        device interface. You can load a file system on top of Amazon EBS volumes,
        or use them just as you would use a block device.
    </p>

    <p class="para">
        You can create up to twenty Amazon EBS volumes of any size (from one GiB up
        to one TiB). Each Amazon EBS volume can be attached to any Amazon EC2
        instance in the same Availability Zone or can be left unattached.
    </p>

    <p class="para">
        Amazon EBS provides the ability to create snapshots of your Amazon EBS volumes
        to Amazon S3. You can use these snapshots as the starting point for new Amazon
        EBS volumes and can protect your data for long term durability.
    </p>

    <div class="section" id="zend.service.amazon.ec2.ebs.creating"><div class="info"><h1 class="title">Create EBS Volumes and Snapshots</h1></div>
        

        <div class="example" id="zend.service.amazon.ec2.ebs.creating.volume"><div class="info"><p><b>Example #1 Create a new EBS Volume</b></p></div>
            

            <div class="example-contents"><p>
                Creating a brand new EBS Volume requires the size and which zone you
                want the EBS Volume to be in.
            </p></div>

            <div class="example-contents"><p>
                <code class="code">createNewVolume</code> will return an array containing information
                about the new Volume which includes the volumeId, size, zone, status
                and createTime.
            </p></div>

            <pre class="programlisting brush: php">
$ec2_ebs = new Zend_Service_Amazon_Ec2_Ebs(&#039;aws_key&#039;,&#039;aws_secret_key&#039;);
$return = $ec2_ebs-&gt;createNewVolume(40, &#039;us-east-1a&#039;);
</pre>

        </div>

        <div class="example" id="zend.service.amazon.ec2.ebs.creating.volumesnapshot"><div class="info"><p><b>Example #2 Create an EBS Volume from a Snapshot</b></p></div>
            

            <div class="example-contents"><p>
                Creating an EBS Volume from a snapshot requires the snapshot_id and which zone you
                want the EBS Volume to be in.
            </p></div>

            <div class="example-contents"><p>
                <code class="code">createVolumeFromSnapshot</code> will return an array containing information
                about the new Volume which includes the volumeId, size, zone, status, createTime and
                snapshotId.
            </p></div>

            <pre class="programlisting brush: php">
$ec2_ebs = new Zend_Service_Amazon_Ec2_Ebs(&#039;aws_key&#039;,&#039;aws_secret_key&#039;);
$return = $ec2_ebs-&gt;createVolumeFromSnapshot(&#039;snap-78a54011&#039;, &#039;us-east-1a&#039;);
</pre>

        </div>

        <div class="example" id="zend.service.amazon.ec2.ebs.creating.snapshot"><div class="info"><p><b>Example #3 Create a Snapshot of an EBS Volume</b></p></div>
            

            <div class="example-contents"><p>
                Creating a Snapshot of an EBS Volume requires the volumeId of the EBS Volume.
            </p></div>

            <div class="example-contents"><p>
                <code class="code">createSnapshot</code> will return an array containing information about the
                new Volume Snapshot which includes the snapshotId, volumeId, status, startTime
                and progress.
            </p></div>

            <pre class="programlisting brush: php">
$ec2_ebs = new Zend_Service_Amazon_Ec2_Ebs(&#039;aws_key&#039;,&#039;aws_secret_key&#039;);
$return = $ec2_ebs-&gt;createSnapshot(&#039;volumeId&#039;);
</pre>

        </div>
    </div>

    <div class="section" id="zend.service.amazon.ec2.ebs.describing"><div class="info"><h1 class="title">Describing EBS Volumes and Snapshots</h1></div>
        

        <div class="example" id="zend.service.amazon.ec2.ebs.describing.volume"><div class="info"><p><b>Example #4 Describing an EBS Volume</b></p></div>
            

            <div class="example-contents"><p>
                <code class="code">describeVolume</code> allows you to get information on an EBS Volume or a set
                of EBS Volumes. If nothing is passed in then it will return all EBS Volumes. If only
                one EBS Volume needs to be described a string can be passed in while an array of
                EBS Volume Id&#039;s can be passed in to describe them.
            </p></div>

            <div class="example-contents"><p>
                <code class="code">describeVolume</code> will return an array with information about each Volume
                which includes the volumeId, size, status and createTime. If the volume is attached
                to an instance, an addition value of attachmentSet will be returned. The attachment
                set contains information about the instance that the EBS Volume is attached to,
                which includes volumeId, instanceId, device, status and attachTime.
            </p></div>

            <pre class="programlisting brush: php">
$ec2_ebs = new Zend_Service_Amazon_Ec2_Ebs(&#039;aws_key&#039;,&#039;aws_secret_key&#039;);
$return = $ec2_ebs-&gt;describeVolume(&#039;volumeId&#039;);
</pre>

        </div>

        <div class="example" id="zend.service.amazon.ec2.ebs.describing.attachedvolumes"><div class="info"><p><b>Example #5 Describe Attached Volumes</b></p></div>
            

            <div class="example-contents"><p>
                To return a list of EBS Volumes currently attached to a running instance you can
                call this method. It will only return EBS Volumes attached to the instance with the
                passed in instanceId.
            </p></div>

            <div class="example-contents"><p>
                <code class="code">describeAttachedVolumes</code> returns the same information as the
                <code class="code">describeVolume</code> but only for the EBS Volumes that are currently attached
                to the specified instanceId.
            </p></div>

            <pre class="programlisting brush: php">
$ec2_ebs = new Zend_Service_Amazon_Ec2_Ebs(&#039;aws_key&#039;,&#039;aws_secret_key&#039;);
$return = $ec2_ebs-&gt;describeAttachedVolumes(&#039;instanceId&#039;);
</pre>

        </div>

        <div class="example" id="zend.service.amazon.ec2.ebs.describing.snapshot"><div class="info"><p><b>Example #6 Describe an EBS Volume Snapshot</b></p></div>
            

            <div class="example-contents"><p>
                <code class="code">describeSnapshot</code> allows you to get information on an EBS Volume
                Snapshot or a set of EBS Volume Snapshots. If nothing is passed in then it will
                return information about all EBS Volume Snapshots. If only one EBS Volume Snapshot
                needs to be described its snapshotId can be passed in while an array of EBS Volume
                Snapshot Id&#039;s can be passed in to describe them.
            </p></div>

            <div class="example-contents"><p>
                <code class="code">describeSnapshot</code> will return an array containing information about each
                EBS Volume Snapshot which includes the snapshotId, volumeId, status, startTime and
                progress.
            </p></div>

            <pre class="programlisting brush: php">
$ec2_ebs = new Zend_Service_Amazon_Ec2_Ebs(&#039;aws_key&#039;,&#039;aws_secret_key&#039;);
$return = $ec2_ebs-&gt;describeSnapshot(&#039;volumeId&#039;);
</pre>

        </div>
    </div>

    <div class="section" id="zend.service.amazon.ec2.ebs.attachdetach"><div class="info"><h1 class="title">Attach and Detaching Volumes from Instances</h1></div>
        

        <div class="example" id="zend.service.amazon.ec2.ebs.attachdetach.attach"><div class="info"><p><b>Example #7 Attaching an EBS Volume</b></p></div>
            

            <div class="example-contents"><p>
                <code class="code">attachVolume</code> will attach an EBS Volume to a running Instance. To
                attach a volume you need to specify the volumeId, the instanceId and the
                device <em class="emphasis">(ex: /dev/sdh)</em>.
            </p></div>

            <div class="example-contents"><p>
                <code class="code">attachVolume</code> will return an array with information about the
                attach status which contains volumeId, instanceId, device, status and
                attachTime
            </p></div>

            <pre class="programlisting brush: php">
$ec2_ebs = new Zend_Service_Amazon_Ec2_Ebs(&#039;aws_key&#039;,&#039;aws_secret_key&#039;);
$return = $ec2_ebs-&gt;attachVolume(&#039;volumeId&#039;, &#039;instanceid&#039;, &#039;/dev/sdh&#039;);
</pre>

        </div>

        <div class="example" id="zend.service.amazon.ec2.ebs.attachdetach.detach"><div class="info"><p><b>Example #8 Detaching an EBS Volume</b></p></div>
            

            <div class="example-contents"><p>
                <code class="code">detachVolume</code> will detach an EBS Volume from a running Instance.
                <code class="code">detachVolume</code> requires that you specify the volumeId with the optional
                instanceId and device name that was passed when attaching the volume. If you need to
                force the detachment you can set the fourth parameter to be
                <b><tt>TRUE</tt></b> and it will force the volume to detach.
            </p></div>

            <div class="example-contents"><p>
                <code class="code">detachVolume</code> returns an array containing status information about
                the EBS Volume which includes volumeId, instanceId, device, status and attachTime.
            </p></div>

            <pre class="programlisting brush: php">
$ec2_ebs = new Zend_Service_Amazon_Ec2_Ebs(&#039;aws_key&#039;,&#039;aws_secret_key&#039;);
$return = $ec2_ebs-&gt;detachVolume(&#039;volumeId&#039;);
</pre>

        </div>

        <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Forced Detach</b><br /></span>
            

            <p class="para">
                You should only force a detach if the previous detachment attempt did not occur
                cleanly (logging into an instance, unmounting the volume, and detaching normally).
                This option can lead to data loss or a corrupted file system. Use this option
                only as a last resort to detach a volume from a failed instance. The instance
                will not have an opportunity to flush file system caches or file system meta
                data. If you use this option, you must perform file system check and repair
                procedures.
            </p>
        </p></blockquote>
    </div>

    <div class="section" id="zend.service.amazon.ec2.ebs.deleting"><div class="info"><h1 class="title">Deleting EBS Volumes and Snapshots</h1></div>
        

        <div class="example" id="zend.service.amazon.ec2.ebs.deleting.volume"><div class="info"><p><b>Example #9 Deleting an EBS Volume</b></p></div>
            

            <div class="example-contents"><p>
                <code class="code">deleteVolume</code> will delete an unattached EBS Volume.
            </p></div>

            <div class="example-contents"><p>
                <code class="code">deleteVolume</code> will return boolean <b><tt>TRUE</tt></b> or
                <b><tt>FALSE</tt></b>.
            </p></div>

            <pre class="programlisting brush: php">
$ec2_ebs = new Zend_Service_Amazon_Ec2_Ebs(&#039;aws_key&#039;,&#039;aws_secret_key&#039;);
$return = $ec2_ebs-&gt;deleteVolume(&#039;volumeId&#039;);
</pre>

        </div>

        <div class="example" id="zend.service.amazon.ec2.ebs.deleting.snapshot"><div class="info"><p><b>Example #10 Deleting an EBS Volume Snapshot</b></p></div>
            

            <div class="example-contents"><p>
                <code class="code">deleteSnapshot</code> will delete an EBS Volume Snapshot.
            </p></div>

            <div class="example-contents"><p>
                <code class="code">deleteSnapshot</code> returns boolean <b><tt>TRUE</tt></b> or
                <b><tt>FALSE</tt></b>.
            </p></div>

            <pre class="programlisting brush: php">
$ec2_ebs = new Zend_Service_Amazon_Ec2_Ebs(&#039;aws_key&#039;,&#039;aws_secret_key&#039;);
$return = $ec2_ebs-&gt;deleteSnapshot(&#039;snapshotId&#039;);
</pre>

        </div>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.service.amazon.ec2.images.html">Zend_Service_Amazon_Ec2: Amazon Machine Images (AMI)</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.service.html">Zend_Service</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.service.amazon.ec2.elasticip.html">Zend_Service_Amazon_Ec2: Elastic IP Addresses</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="reference.html">Refer&ecirc;ncia do Zend Framework</a></li>
  <li class="header up"><a href="zend.service.html">Zend_Service</a></li>
  <li><a href="zend.service.introduction.html">Introdu&ccedil;&atilde;o</a></li>
  <li><a href="zend.service.akismet.html">Zend_Service_Akismet</a></li>
  <li><a href="zend.service.amazon.html">Zend_Service_Amazon</a></li>
  <li><a href="zend.service.amazon.ec2.html">Zend_Service_Amazon_Ec2</a></li>
  <li><a href="zend.service.amazon.ec2.instance.html">Zend_Service_Amazon_Ec2: Instances</a></li>
  <li><a href="zend.service.amazon.ec2.windows.instance.html">Zend_Service_Amazon_Ec2: Windows Instances</a></li>
  <li><a href="zend.service.amazon.ec2.reserved.instance.html">Zend_Service_Amazon_Ec2: Reserved Instances</a></li>
  <li><a href="zend.service.amazon.ec2.cloudwatch.html">Zend_Service_Amazon_Ec2: CloudWatch Monitoring</a></li>
  <li><a href="zend.service.amazon.ec2.images.html">Zend_Service_Amazon_Ec2: Amazon Machine Images (AMI)</a></li>
  <li class="active"><a href="zend.service.amazon.ec2.ebs.html">Zend_Service_Amazon_Ec2: Elastic Block Storage (EBS)</a></li>
  <li><a href="zend.service.amazon.ec2.elasticip.html">Zend_Service_Amazon_Ec2: Elastic IP Addresses</a></li>
  <li><a href="zend.service.amazon.ec2.keypairs.html">Zend_Service_Amazon_Ec2: Keypairs</a></li>
  <li><a href="zend.service.amazon.ec2.zones.html">Zend_Service_Amazon_Ec2: Regions and Availability Zones</a></li>
  <li><a href="zend.service.amazon.ec2.securitygroups.html">Zend_Service_Amazon_Ec2: Security Groups</a></li>
  <li><a href="zend.service.amazon.s3.html">Zend_Service_Amazon_S3</a></li>
  <li><a href="zend.service.amazon.sqs.html">Zend_Service_Amazon_Sqs</a></li>
  <li><a href="zend.service.audioscrobbler.html">Zend_Service_Audioscrobbler</a></li>
  <li><a href="zend.service.delicious.html">Zend_Service_Delicious</a></li>
  <li><a href="zend.service.developergarden.html">Zend_Service_DeveloperGarden</a></li>
  <li><a href="zend.service.ebay.html">Zend_Service_Ebay</a></li>
  <li><a href="zend.service.ebay.finding.html">Zend_Service_Ebay_Finding</a></li>
  <li><a href="zend.service.flickr.html">Zend_Service_Flickr</a></li>
  <li><a href="zend.service.livedocx.html">Zend_Service_LiveDocx</a></li>
  <li><a href="zend.service.nirvanix.html">Zend_Service_Nirvanix</a></li>
  <li><a href="zend.service.recaptcha.html">Zend_Service_ReCaptcha</a></li>
  <li><a href="zend.service.short-url.html">Zend_Service_ShortUrl</a></li>
  <li><a href="zend.service.simpy.html">Zend_Service_Simpy</a></li>
  <li><a href="zend.service.slideshare.html">Zend_Service_SlideShare</a></li>
  <li><a href="zend.service.strikeiron.html">Zend_Service_StrikeIron</a></li>
  <li><a href="zend.service.strikeiron.bundled-services.html">Zend_Service_StrikeIron: Bundled Services</a></li>
  <li><a href="zend.service.strikeiron.advanced-uses.html">Zend_Service_StrikeIron: Advanced Uses</a></li>
  <li><a href="zend.service.technorati.html">Zend_Service_Technorati</a></li>
  <li><a href="zend.service.twitter.html">Zend_Service_Twitter</a></li>
  <li><a href="zend.service.windowsazure.html">Zend_Service_WindowsAzure</a></li>
  <li><a href="zend.service.windowsazure.storage.blob.html">Zend_Service_WindowsAzure_Storage_Blob</a></li>
  <li><a href="zend.service.windowsazure.diagnostics.manager.html">Zend_Service_WindowsAzure_Diagnostics_Manager</a></li>
  <li><a href="zend.service.windowsazure.storage.queue.html">Zend_Service_WindowsAzure_Storage_Queue</a></li>
  <li><a href="zend.service.windowsazure.storage.table.html">Zend_Service_WindowsAzure_Storage_Table</a></li>
  <li><a href="zend.service.yahoo.html">Zend_Service_Yahoo</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>